/**   
 * Copyright © 2019 eSunny Info. Tech Ltd. All rights reserved.
 * 
 * @Description:TODO(功能)
 * @className EmployeesServiceImpl.java
 * @Package: com.erp.service 
 * @author: yj   
 * @date: 2019年2月22日 下午3:51:16 
 */
package com.erp.service;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.erp.dao.EmployeesDaoImpl;
import com.erp.po.Employees;
import com.erp.util.DBHelper;

/**
 * @className EmployeesServiceImpl.java
 * @author yj
 * @Description:TODO(功能)
 * @Date 2019年2月22日
 */
public class EmployeesServiceImpl implements EmployeesService {

	private EmployeesDaoImpl ed;
	
	public EmployeesServiceImpl() {
		ed = new EmployeesDaoImpl();
	}
	
	/* 
	 * 查询所有员工信息
	 */
	@Override
	public List<Employees> findAllEmps() {
		Connection conn = null;
		ArrayList<Employees> list = new ArrayList<Employees>();
		
		try {
			conn = DBHelper.getConnection();
			
			ResultSet set = ed.selectAllEmps(conn);
			while (set.next()) {
				int empID = set.getInt("EMPID");
				String empName = set.getString("EMP_NAME");
				
				list.add(new Employees(empID, empName));
			}
			return list;
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			ed.close();
		}
		return null;
	}

}
